﻿
namespace ExampleCodesLib
{
    public class TriangleTypes
    {
        /// <summary>
        /// A function that receives three integer input for the lengths of the sides of a triangle
        /// and returns one of four values to determine the triangle type.
        /// </summary>
        /// <param name="s1">the length of one side of a triangle</param>
        /// <param name="s2">the length of one side of a triangle</param>
        /// <param name="s3">the length of one side of a triangle</param>
        /// <returns>
        /// 1 = scalene
        /// 2 = isosceles
        /// 3 = equilateral
        /// 4 = error
        /// </returns>
        public static int GetTriangleType(int s1, int s2, int s3)
        {
            int type = 4;
            //Triangle Inequality Theorem:
            //For any triangle, the sum of the lengths of any two sides must be greater than the length of the remaining side.
            if (s1 + s2 > s3 && s1 + s3 > s2 && s2 + s3 > s1)
            {
                if (s1 == s2 && s1 == s3)
                {
                    type = 3;
                }
                else if (s1 == s2 || s1 == s3 || s2 == s3)
                {
                    type = 2;
                }
                else
                {
                    type = 1;
                }
            }
            return type;
        }
    }
}
